package com.shao.Dao.impl;

import com.shao.Dao.UserDao;
import com.shao.Dao.impl.BaseDao;
import com.shao.pojo.User;

/**
 * Created with IntelliJ IDEA.
 * User: SJP
 * Date: 2021/5/12
 * Time: 9:25
 * Description: No Description
 */
public class UserDaoImpl extends BaseDao implements UserDao {
    @Override
    public User queryUserByUsername(String username) {
        String sql = "select `id`, `username`, `password` ,`email` from b_user where username = ?";
        return QueryForOne(User.class,sql,username);
    }

    @Override
    public User queryUserByUsesnameAndPassword(String username, String password) {
        String sql = "select `id`, `username`, `password`, `email` from b_user where username = ? and password = ?";
        return QueryForOne(User.class,sql,username,password);
    }

    @Override
    public int saveUser(User user) {
        String sql = "insert into b_user(`username`,`password`,`email`) values(?,?,?) ";
        return update(sql,user.getUsername(),user.getPassword(),user.getEmail());
    }
}
